import { Directive, Input, OnInit, ViewContainerRef, TemplateRef } from '@angular/core';

@Directive({
  selector: '[virtualItem]'
})
export class VirtualItemDirective implements OnInit {
  @Input()
  set virtualItem(list: any) {
    list.forEach((element, key) => {
      this.vcr.createEmbeddedView(this.tpl, {
        $implicit: element,
        key
      });
    });
  }
  constructor(private vcr: ViewContainerRef, private tpl: TemplateRef<any>) { }
  ngOnInit(): void {
  }
}
